var api = require('../../utils/api.js');
var app = getApp();


Page({

    /**
     * 页面的初始数据
     */
    data: {
        text:'',
        catetit:'',
        cates:[]
    },

    gettext(ret){
        this.setData({
            text:ret.detail.value
        })
    },

    bindPickerChange(ret){
        console.log(ret);
        var list=this.data.cates;
        var index=ret.detail.value;

        this.setData({
            catetit:list[index]
        })

    },

    onShow(){
        var that=this;

        api.post({
            url: 'user/gettscate',
            data: {},
            success: data => {
                console.log(data);

                that.setData({
                    cates:data.data
                })
               
            }
        });
    },
    submits(){

        var text=this.data.text;
        var catetit=this.data.catetit;


        var that=this;
        api.post({
            url: 'user/toushu',
            data: {text:text,catetit:catetit},
            success: data => {
                console.log(data);
                wx.showToast({
                  title: data.msg,
                  icon:'none'
                })
            }
        });


    }
    
})